﻿using DevExpress.Mvvm.Gantt;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace DevWpfApp
{
    public class GanttResourceLinkCollectionProxy
    {
        public GanttResourceLinkCollectionProxy()
        {
        }

        public ObservableCollection<GanttResourceLink> Links
        {
            get;
            set;
        }

        [DataMember]
        public ObservableCollection<GanttResourceLinkProxy> LinkProxies
        {
            set
            {
                if (Links == null)
                    Links = new ObservableCollection<GanttResourceLink>();
                Links.Clear();
                foreach (var link in value)
                {
                    Links.Add(link.Link);
                }
            }
            get
            {
                if (Links == null)
                    Links = new ObservableCollection<GanttResourceLink>();
                ObservableCollection<GanttResourceLinkProxy> r = new ObservableCollection<GanttResourceLinkProxy>();
                foreach (var link in Links)
                {
                    r.Add(new GanttResourceLinkProxy { Link = link });
                }
                return r;
            }
        }
    }
}
